<?php

/**
 * This is the model class for table "goods_native".
 *
 * The followings are the available columns in table 'goods_native':
 * @property integer $id ID
 * @property integer $goods_id Goods
 * @property string $desc 商品描述
 */
class GoodsNative extends ActiveRecord
{
	public $num = '';
	/**
	 * Returns the static model of the specified AR class.
	 * @return GoodsNative the static model class
	 */
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
	
	public function getMdcClass() {
		return 'application.models.metadata.GoodsNativeMetadata';
	}
	
	static public function getFieldCount($city) {
		$model = new self();
		$criteria = new CDbCriteria();
		$criteria->compare('field', $city);
		return $model->count($criteria);
	}
	
	static public function fieldCity() {
		$criteria = new CDbCriteria();
		$criteria->with = array('goods');
		$criteria->group = 'field';
		$criteria->compare('status', 'ST_PASSED');
		$criteria->compare('listing_status', 'ST_LISTING');
		
		$models = self::model()->findAll($criteria);
		$arr = array(''=>'不限');
		foreach ($models as $one) {
			$arr[$one->field] = LyUtis::cityName($one->field);
		}
		return $arr;
	}
}